package com.yitiao.data_algorithms.leetcode.editor.cn;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;

class NThTribonacciNumber{
    // 2022-09-01 12:38:34
    public static void main(String[] args) {
        Solution solution = new NThTribonacciNumber().new Solution();
    }
    
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int tribonacci(int n) {
        int[] ans = new int[n+1];
        if (n==0){
            return 0;
        }else if (n<=2)return 1;
        ans[0]=0;ans[1]=1;ans[2]=1;
        for (int i = 3; i <=n ; i++) {
            ans[i] = ans[i-3]+ans[i-2]+ans[i-1];
        }
        return ans[n];

    }
}
//leetcode submit region end(Prohibit modification and deletion)

}